/*
 * @Description: 
 * @FilePath: \网易云音乐e:\CSS+HTML+JS+\学习笔记\代码测试\算法\字符串\922.按奇偶排序数组-ii.js
 */ 
/*
 * @lc app=leetcode.cn id=922 lang=javascript
 *
 * [922] 按奇偶排序数组 II
 */

// @lc code=start
/**
 * @param {number[]} A
 * @return {number[]}
 */
var sortArrayByParityII = function(A) {
    let even = 1,
        odd = 0;
    
    let arr = [];
    for(let i = 0; i < A.length; i++) {
        let temp;
        if(A[i] % 2 != 0) {
            arr[even] = A[i];
            even += 2;
        } else {
            arr[odd] = A[i];
            odd += 2;
        }
    }
    console.log(arr);
    return arr;
};
let res = sortArrayByParityII([4,2,5,7,7])
// @lc code=end

